#pragma once

#include "driver/gpio.h"

// rtc端口，不上下拉就正常使用
// pwm功能不可用
// The GPIO of esp8266 can not be pulled down except RTC GPIO which can not be pulled up.
# define NUM_D0 GPIO_NUM_16
// 普通端口正常使用, pwm功能正常
# define NUM_D1 GPIO_NUM_5
# define NUM_D2 GPIO_NUM_4
# define NUM_D3 GPIO_NUM_0
# define NUM_D4 GPIO_NUM_2 // led pin
# define NUM_D5 GPIO_NUM_14
# define NUM_D6 GPIO_NUM_12
# define NUM_D7 GPIO_NUM_13
# define NUM_D8 GPIO_NUM_15
// 有特殊含义, pwm功能可用
# define NUM_RX GPIO_NUM_3
// 用了pwm后，无法输出debug信息到串口
# define NUM_TX GPIO_NUM_1 
// spi数据接口
// pwm功能不可用
# define NUM_SD0 GPIO_NUM_7
# define NUM_SD1 GPIO_NUM_8
# define NUM_SD2 GPIO_NUM_9
# define NUM_SD3 GPIO_NUM_10
# define NUM_SD_CMD GPIO_NUM_11
# define NUM_SD_CLK GPIO_NUM_6

// 照明板子上的对应rj45的pin
#define LIGHT_RJ45_D8 NUM_D3
#define LIGHT_RJ45_D6 NUM_D4
#define LIGHT_RJ45_D4 NUM_D5
#define LIGHT_RJ45_D3 NUM_D6
#define LIGHT_RJ45_D5 NUM_D7
#define LIGHT_RJ45_D7 NUM_D8

void gpio_pin_init(gpio_num_t pin_num, 
                gpio_mode_t mode /* od模式需要外部上拉下拉，非特殊需求别用 */, 
                gpio_int_type_t int_type = GPIO_INTR_DISABLE /* 默认不用触发器 */) {
    gpio_config_t cfg;
    cfg.pin_bit_mask = BIT(pin_num);
    cfg.mode = mode;
    cfg.pull_up_en = GPIO_PULLUP_DISABLE;
    cfg.pull_down_en = GPIO_PULLDOWN_DISABLE;
    cfg.intr_type = int_type;
    gpio_config(&cfg);
    
}


